﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using RJ.Objects.GameEngine;
using System.Drawing;

namespace RJ.Euchre.App.Game
{
    public class EuchreSettings : GameSettings
    {
        public EuchreSettings()
            : base()
        {
            InitializeDefaultSettings();
        }

        private void InitializeDefaultSettings()
        {
            CardBack = 1;
            HumanPlayers = 1;
            QuadrantModifiers = new Point[]
            {
                new Point(-1, -1),
                new Point( 1, -1),
                new Point(-1,  1),
                new Point( 1,  1)
            };
            DistanceModifier = new Point[]
            {
                new Point(1, 1),
                new Point(0, 1),
                new Point(1, 0),
                new Point(0, 0)
            };
        }

        public int CardBack
        {
            get { return GetSetting<int>("cardback"); }
            set { AddSetting("cardback", value); }
        }

        public int HumanPlayers
        {
            get { return GetSetting<int>("humanplayers"); }
            set { AddSetting("humanplayers", value); }
        }

        public Point[] QuadrantModifiers
        {
            get { return GetSetting<Point[]>("quadrantmodifiers"); }
            set { AddSetting("quadrantmodifiers", value); }
        }

        public Point[] DistanceModifier
        {
            get { return GetSetting<Point[]>("distancemodifier"); }
            set { AddSetting("distancemodifier", value); }
        }


        public override void AddSetting(string name, object value)
        {
            if (!settings.ContainsKey(name))
                settings.Add(name, value);
            else
                settings[name] = value;
        }

        public override TReturn GetSetting<TReturn>(string name)
        {
            if (settings.ContainsKey(name))
                return (TReturn)settings[name];
            return default(TReturn);
        }
    }
}
